﻿
if col_length('ERPStoreOffersEntitySelectedDetailExtension', 'IsStrikedPrice') is not null
Begin 
	alter table dbo.ERPStoreOffersEntitySelectedDetailExtension drop column IsStrikedPrice
End
Go

if col_length('ERPStoreOffersEntitySelectedDetailExtension', 'StikedPrice') is null
Begin
	alter table ERPStoreOffersEntitySelectedDetailExtension add StikedPrice bigint null
end
Go

alter view dbo.ERPStoreOffersOfferedProduct
As
Select 
EntitySelectionDetail.Id as Id
, InternalEntityId as ProductId
, EntitySelectionDetail.EntitySelectionId as SelectionId
, ERPStoreOffersEntitySelectedDetailExtension.SalePrice
, ERPStoreOffersEntitySelectedDetailExtension.StikedPrice
, ERPStoreOffersEntitySelectedDetailExtension.Discount
, ERPStoreOffersEntitySelectedDetailExtension.SaleFactor
From EntitySelection
		join EntitySelectionDetail on EntitySelection.Id = EntitySelectionDetail.EntitySelectionId
		left join ERPStoreOffersEntitySelectedDetailExtension on EntitySelectionDetail.Id = ERPStoreOffersEntitySelectedDetailExtension.ERPStoreOffersEntitySelectedDetailExtensionId
where EntitySelection.EntityNameBase = 'Product'
Go
